package au.edu.educationau.opensource.dsm.obj;

import java.util.Date;

import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * An instance of this class is created for every search or paging request
 * received by DSM (all servlets) and saved to the database for creating stats.
 * 
 * @author bslattery
 */
public class SearchTermHistory {
	/** the query string he user submitted to DSM (ie. the value of q=) */
	private String searchQuery;
	/** comma separated search sources */
	private String searchSources;
	/**
	 * token generated by DSM (for first search) or given on request (for
	 * paging)
	 */
	private long searchToken;
	/** off the HttpServletRequest */
	private String requestUrl;
	/**
	 * the total number of results found (from all sources) so far (ie. some
	 * searches may still be running when this row is written)
	 */
	private int resultCount;
	/** equal to the longest duration out of all the searches */
	private int queryDuration;
	/** as from HttpServletRequest, or from HTTP headers if given */
	private String ipAddress;
	/** from HTTP header */
	private String userAgent;
	/** date/time of request */
	private Date dateRecorded;

	public Date getDateRecorded() {
		return dateRecorded;
	}

	public void setDateRecorded(Date dateRecorded) {
		this.dateRecorded = dateRecorded;
	}

	public String getIpAddress() {
		return ipAddress;
	}

	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}

	public int getQueryDuration() {
		return queryDuration;
	}

	public void setQueryDuration(int queryDuration) {
		this.queryDuration = queryDuration;
	}

	public String getRequestUrl() {
		return requestUrl;
	}

	public void setRequestUrl(String requestUrl) {
		this.requestUrl = requestUrl;
	}

	public int getResultCount() {
		return resultCount;
	}

	public void setResultCount(int resultCount) {
		this.resultCount = resultCount;
	}

	public String getSearchQuery() {
		return searchQuery;
	}

	public void setSearchQuery(String searchQuery) {
		this.searchQuery = searchQuery;
	}

	public String getSearchSources() {
		return searchSources;
	}

	public void setSearchSources(String searchSources) {
		this.searchSources = searchSources;
	}

	public long getSearchToken() {
		return searchToken;
	}

	public void setSearchToken(long searchToken) {
		this.searchToken = searchToken;
	}

	public String getUserAgent() {
		return userAgent;
	}

	public void setUserAgent(String userAgent) {
		this.userAgent = userAgent;
	}

	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}